#include <jack/jack.h>
#include <glib-2.0/glib.h>
/**
 * add to edit /etc/security/limits.conf and add
 *  @audio - memlock unlimited
 * need to add a check for that
 */



const char **jack_get_input_devices() {
    
    const char **ports;
    const char *client_name = "tuxinstudio";
    const char *server_name = NULL;
    jack_options_t options = JackNoStartServer;
    jack_status_t status;
    jack_client_t *client;

    client = jack_client_open(client_name,options,&status,server_name);
    if (client == NULL) {
        g_debug("jack client open failed. status 0x%2.0x",status);                
        ports=NULL;
        return ports;
    }
    if (status & JackNameNotUnique) {
        client_name = jack_get_client_name(client);
        g_debug("unique name `%s' assigned\n", client_name);
    }    
    ports = jack_get_ports (client, NULL, NULL,JackPortIsPhysical|JackPortIsInput);
   
    if (ports == NULL) {
        g_debug("no physical capture ports\n");
    }    
    return ports;
}

void jack_free_ports_array(const char **ports) {
    jack_free(ports);
}